home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #6 / Amiga Plus CD - 2004 - No. 06.iso / AmiSoft / Dev / src / Apfelberge.lha / Apfelberge / joystick.h < prev    next >
C/C++ Source or Header  |  2004-04-28  |  957b  |  48 lines

  1. /* CC65's new joystick API */
  2.  
  3. #ifndef _JOYSTICK_H
  4. #define _JOYSTICK_H
  5.  
  6. #define __JOYSTICK__
  7. #ifndef __SASC
  8. #include <proto/exec.h>
  9. struct Library *LowLevelBase;
  10. #endif
  11. #include <proto/lowlevel.h>
  12. enum {JOY_ERR_OK, JOY_ERR_NO_DRIVER, JOY_ERR_CANNOT_LOAD, JOY_ERR_INV_DRIVER, JOY_ERR_NO_DEVICE};
  13. enum {JOY_1, JOY_2};
  14. #define JOY_BTN_UP(v)        ((v) & JPF_JOY_UP)
  15. #define JOY_BTN_DOWN(v)        ((v) & JPF_JOY_DOWN)
  16. #define JOY_BTN_LEFT(v)        ((v) & JPF_JOY_LEFT)
  17. #define JOY_BTN_RIGHT(v)    ((v) & JPF_JOY_RIGHT)
  18. #define JOY_BTN_FIRE(v)        ((v) & JPF_BUTTON_RED)
  19.  
  20. const char joy_stddrv[]="";
  21.  
  22. __inline char joy_load_driver(const char *driver)
  23. {
  24. #ifndef __SASC
  25. LowLevelBase=OldOpenLibrary("lowlevel.library");
  26. #endif
  27. return driver=="" ? JOY_ERR_OK : JOY_ERR_NO_DRIVER;
  28. }
  29.  
  30. __inline char joy_count(void)
  31. {
  32. return 2;
  33. }
  34.  
  35. __inline joy_read(char port)
  36. {
  37. return (int) ReadJoyPort(port);
  38. }
  39.  
  40. __inline void joy_unload(void)
  41. {
  42. #ifndef __SASC
  43. CloseLibrary(LowLevelBase);
  44. #endif
  45. }
  46.  
  47. #endif
  48.